#pragma once

#include "Angel.h"
#include <string.h>

#define theDialog HSDialog::GetInstance()

struct HSDialogReply
{
	std::string sReplyText;
	std::string sVisibilityCondition;
	std::string sOnSelectAction;
	std::string sNextPrompt;

	HSDialogReply();

	bool IsAvailable();
	bool DoOnSelectAction();
};

struct HSDialogScreen
{
	std::string sId;

	std::string sPrompt;
	unsigned int uiValidReplies;
	HSDialogReply reply[5];

	HSDialogScreen();
};

class HSDialog : public MouseListener
{

protected:

	typedef std::map<std::string, HSDialogScreen> HSDialogScreenMap;
	static HSDialogScreenMap smapDialogs;

	static const int iCanvasLayer = 1000;
	static const int iPromptLayer = 1001;
	static const int iRepliesLayer = 1002;

	bool bActive;
	static HSDialog* sDialog;

	void MouseMotionEvent(Vec2i screenCoordinates); 
	void MouseDownEvent(Vec2i screenCoordinates, MouseButtonInput button); 
	void MouseUpEvent(Vec2i screenCoordinates, MouseButtonInput button); 
	void MouseWheelEvent(const Vector2 &scrollOffset);

	HSDialogScreen* pDialogScreen;

	Actor aCanvas;
	TextActor taPrompt;
	TextActor taReplies[5];

public:

	HSDialog();
	~HSDialog();

	void Activate();
	void Deactivate();

	bool ShowDialog( const std::string& sDialogId );

	static HSDialog& GetInstance();
	static bool LoadDialogs( const std::string& sDialogDefs );
};
